home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / eiffel / smalleif.97 / se.t / SmallEiffel / lib_std / character_ref.e < prev    next >
Encoding:
Text File  |  1996-05-02  |  1.0 KB  |  54 lines

  1. -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C) 
  2. -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
  3. --
  4. class CHARACTER_REF
  5.  
  6. inherit COMPARABLE redefine infix "<", compare end;
  7.    
  8. creation {ANY}
  9.    make
  10.  
  11. feature {ANY}
  12.    
  13.    item: CHARACTER;
  14.  
  15.    make(value: CHARACTER) is
  16.       do
  17.      item := value;
  18.       end;
  19.     
  20.    infix "<" (other: like Current): BOOLEAN is
  21.      -- Is Current less than `other'?
  22.       do
  23.      Result := item < other.item
  24.       end;
  25.  
  26.    compare (other: like Current) : INTEGER is
  27.      -- Compare Current with `other'.
  28.      -- '<' <==> Result < 0
  29.      -- '>' <==> Result > 0
  30.      -- Otherwise Result = 0
  31.       do
  32.      Result := code - other.code
  33.       end;
  34.  
  35.    code: INTEGER is
  36.      -- ASCII code of Current
  37.       do
  38.      Result := item.code
  39.       end;
  40.    
  41.    to_upper: like Current is
  42.      -- Conversion of Current to upper case
  43.       do
  44.      !!Result.make (item.to_upper)
  45.       end;
  46.  
  47.    to_lower: like Current is
  48.      -- Conversion of Current to lower case
  49.       do
  50.      !!Result.make (item.to_lower)
  51.       end;
  52.  
  53. end -- CHARACTER_REF
  54.